using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using IGlobalist.Cms.Bll;
using IGlobalist.Cms.Model;
using IGlobalist.Cms.Common;

namespace IGlobalist.Cms.Admin
{
    public partial class CategoryManagement : AdminBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ucCategoryTree.DataBind();
                ucActionBar.ObjectTypeCurrent = CmsObjectType.ContentCategory;
                ucActionBarBottom.ObjectTypeCurrent = CmsObjectType.ContentCategory;
            }
            ucCategoryTree.TreeNodeClick += ucCategoryAddEdit.DoEditCategory;
            ucCategoryTree.TreeNodeClick += ucCategoryAddEdit.DoShow;
            ucCategoryTree.TreeNodeClick += ucActionBar.DoListEditClick;
            ucCategoryTree.TreeNodeClick += ucActionBarBottom.DoListEditClick;
            ucCategoryTree.TreeNodeClick += ucContentView.DoHidden; 
            ucCategoryTree.TreeNodeClick += ucContentListView.DoHidden;
            ucCategoryTree.TreeNodeClick += HiddenInfo;
            
            
            ucActionBar.NewButtonClick += ucCategoryAddEdit.DoShow;            
            ucActionBar.NewButtonClick += ucCategoryAddEdit.DoNewCategory;
            ucActionBar.NewButtonClick += ucContentView.DoHidden;
            ucActionBar.NewButtonClick += ucContentListView.DoHidden;
            ucActionBar.NewButtonClick += HiddenInfo;
            ucActionBarBottom.NewButtonClick += ucCategoryAddEdit.DoShow;
            ucActionBarBottom.NewButtonClick += ucCategoryAddEdit.DoNewCategory;
            ucActionBarBottom.NewButtonClick += ucContentView.DoHidden;
            ucActionBarBottom.NewButtonClick += ucContentListView.DoHidden;
            ucActionBarBottom.NewButtonClick += HiddenInfo;
            ucActionBarBottom.NewButtonClick += ucActionBar.DoEditClassClick;
            ucActionBar.NewButtonClick += ucActionBarBottom.DoEditClassClick;
            ucActionBarBottom.NewButtonClick += ucActionBarBottom.DoEditClassClick;
            ucActionBar.NewButtonClick += ucActionBar.DoEditClassClick;

            ucActionBar.DeleteButtonClick += ucCategoryTree.DoDeleteCategory;
            ucActionBar.DeleteButtonClick += ucCategoryAddEdit.DoShow; 
            ucActionBar.DeleteButtonClick += ucCategoryAddEdit.DoNewCategory;
            ucActionBarBottom.DeleteButtonClick += ucCategoryTree.DoDeleteCategory;
            ucActionBarBottom.DeleteButtonClick += ucCategoryAddEdit.DoShow;
            ucActionBarBottom.DeleteButtonClick += ucCategoryAddEdit.DoNewCategory;
            ucActionBar.DeleteButtonClick += ucActionBar.DoEditClassClick;
            ucActionBar.DeleteButtonClick += ucActionBarBottom.DoEditClassClick;
            ucActionBarBottom.DeleteButtonClick += ucActionBarBottom.DoEditClassClick;
            ucActionBarBottom.DeleteButtonClick += ucActionBar.DoEditClassClick;


            ucCategoryAddEdit.ViewContent += ucContentListView.DoBindCategoryContent;
            ucCategoryAddEdit.ViewContent += ucCategoryAddEdit.DoHidden;
            ucCategoryAddEdit.ViewContent += ucContentListView.DoShow;

            ucContentListView.EditContent += ucContentView.DoBindContent;
            ucContentListView.EditContent += ucContentView.DoShow;
            ucContentListView.EditContent += ucContentListView.DoHidden;

            if (ucContentView.Visible == true)
            {
                ucActionBar.SaveButtonClick += ucContentView.DoSaveContent;
                ucActionBar.SaveButtonClick += ucContentListView.DoShow;
                ucActionBar.SaveButtonClick += ucContentView.DoHidden;
                ucActionBar.SaveButtonClick += ucActionBar.DoEditClassClick;
                ucActionBar.SaveButtonClick += ucActionBarBottom.DoEditClassClick;


                ucActionBarBottom.SaveButtonClick += ucContentView.DoSaveContent;
                ucActionBarBottom.SaveButtonClick += ucContentListView.DoShow;
                ucActionBarBottom.SaveButtonClick += ucContentView.DoHidden;
                ucActionBarBottom.SaveButtonClick += ucActionBar.DoEditClassClick;
            }

            if (ucCategoryAddEdit.Visible == true)
            {
                ucActionBar.SaveButtonClick += ucContentView.DoHidden;
                ucActionBar.SaveButtonClick += ucContentListView.DoHidden;
                ucActionBar.SaveButtonClick += ucCategoryAddEdit.DoSaveCategory;
                ucActionBarBottom.SaveButtonClick += ucContentView.DoHidden;
                ucActionBarBottom.SaveButtonClick += ucContentListView.DoHidden;
                ucActionBarBottom.SaveButtonClick += ucCategoryAddEdit.DoSaveCategory;
                ucCategoryAddEdit.EventSaveSuccess += ucCategoryTree.BindCategory;
                ucCategoryAddEdit.EventSaveSuccess += ucCategoryAddEdit.DoShow;
            }

                
        }

        public void HiddenInfo(object sender, EventArgs e)
        {
            pnlInfo.Visible = false;
        }
    }
}
